package mrHunter.puzzles.array;

public class Puzzle6 {
    //Puzzle3
    public String kthOccurrence(String input){
        //int[] A, int n, int x, int k
        //int y
        String[] inputArray=input.split(",");
        String[] AArray=inputArray[0].split(" ");
        int[] A=new int[AArray.length];
        for(int i=0;i<AArray.length;i++){
            A[i]=Integer.parseInt(AArray[i]);
        }
        int x=Integer.parseInt(inputArray[1]);
        int k=Integer.parseInt(inputArray[2]);

        int occurrence=0;
        for(int i=0;i<AArray.length;i++){
            if(A[i]==x){
                occurrence++;
                if(occurrence==k)
                    return String.valueOf(i);
            }
        }
        return "-1";
    }
}
